home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / host / Host_ByID.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-05  |  1.6 KB  |  61 lines

  1. /* 
  2.  * Host_ByID.c --
  3.  *
  4.  *    Source code for the Host_ByID library procedure.
  5.  *
  6.  * Copyright 1988 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  */
  15.  
  16. #ifndef lint
  17. static char rcsid[] = "$Header: Host_ByID.c,v 1.2 88/08/08 13:25:04 ouster Exp $ SPRITE (Berkeley)";
  18. #endif not lint
  19.  
  20. #include <stdio.h>
  21. #include <host.h>
  22. #include <hostInt.h>
  23.  
  24.  
  25. /*
  26.  *-----------------------------------------------------------------------
  27.  *
  28.  * Host_ByID --
  29.  *
  30.  *    Return info about a host based on its Sprite ID.
  31.  *
  32.  * Results:
  33.  *    A pointer to a Host_Entry structure, or NULL if no machine
  34.  *    with that ID exists.  The Host_Entry is statically allocated,
  35.  *    and may be modified on the next call to any Host_ procedure.
  36.  *
  37.  * Side Effects:
  38.  *    The host database is opened if it wasn't already so.
  39.  *
  40.  *-----------------------------------------------------------------------
  41.  */
  42. Host_Entry *
  43. Host_ByID(id)
  44.     register int      id;          /* ID of machine to find */
  45. {
  46.     register Host_Entry    *entry;            /* Current entry in database */
  47.  
  48.     if (Host_Start() != 0) {
  49.     return (Host_Entry *) NULL;
  50.     }
  51.     
  52.     while (1) {
  53.     entry = Host_Next();
  54.     if (entry == (Host_Entry *) NULL) {
  55.         return entry;
  56.     } else if (entry->id == id) {
  57.         return (entry);
  58.     }
  59.     }
  60. }
  61.